I have a string output (buffer) and want to paste this into an excel file in a file location. Then 'Save As' with a new filename appended with datetime stamp. Note this excel has a macro that I would like to preserve in the new saved copy. Please help with some working code snippet. Thanks!
|
Re: Save As Excel file Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Save As Excel file There is a nice exel example in DOORS lib, here is small part of it:
/*
* This funciton saves the file as the passed in file name.
*/
void saveFileAs(string filename) {
if(!fileOpen) {
io4log << "ERRO : File not open\n";
halt;
}
clear(args);
put(args, "FileName", filename);
checkRes(oleMethod(objWorkbook, "SaveAs", args))
io4log << "INFO : File saved as " filename "\n";
}
string ZeroPrefixedInt(int i)
{
string s = i ""
if (i < 10)
s = "0" s
return s
}
string getZeroPrefixedTime()
{
int now = intOf(dateAndTime(today))
Date d = dateOnly(today)
int day = intOf(date(stringOf(d)))
int diff = now-day
int hours = diff / 3600
int mins = (diff - (3600 * hours)) / 60
int secs = diff - (hours * 3600) - (mins * 60)
return(ZeroPrefixedInt(hours) ZeroPrefixedInt(mins) ZeroPrefixedInt(secs))
}
string FileTimeStamp = stringOf(today,"yyyyMMdd") "-" getZeroPrefixedTime() string fname_ExcelExport = "DOORS_ExcelExport_" FileTimeStamp ".xls" saveFileAs(fname_ExcelExport)
|